<?php
$con = mysql_connect("localhost","root","root");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("tlck", $con);
$dateTime = date("Y-m-d",strtotime("-1 day"));
#$dateTime = '2012-03-28';
$logdate =  mysql_query("SELECT DISTINCT dataTime FROM `tlck_query`");
while($everylogdate = mysql_fetch_array($logdate))
{
  mysql_query("INSERT INTO tlck_query_temp
SELECT max(id),
        task,
        lastUi,
        dayUI1Count,
        dayUI2Count,
        dayUI3Count,
        dayUI4Count,
        dayUI5Count,
        dayUI6Count,
        fightNum,
        DailyTCNum,
        dayPlayShortTime,
        dayPlayLongTime,
        dayUsedMoney,
        p1lastLevel,
        p2lastLevel,
        p3lastLevel,
        DailyTCTimes,
        succNum,
        nowMoney,
        dayTotalTime,
        firstlogindata,
        firstlogin,
        dayPlayAvgTime,
        dayGetMoney,
        totalTime,
        totalMoney,
        jailbreak,
        dayPlayTime,
        lastLevel,
        equipUsedInfos,
        A1,
        A2,
        A3,
        A4,
        A5,
        A6,
        A7,
        A8,
        A9,
        A10,
        A11,
        A12,
        A13,
        A14,
        B1,
        B2,
        B3,
        B4,
        B5,
        B6,
        B7,
        B8,
        B9,
        B10,
        C1,
        C2,
        C3,
        C4,
        C5,
        C6,
        C7,
        C8,
        C9,
        C10,
        D1,
        D2,
        D3,
        D4,
        D5,
        D6,
        D7,
        D8,
        D9,
        D10,
        E1,
        E2,
        E3,
        E4,
        E5,
        E6,
        E7,
        E8,
        E9,
        E10,
        F1,
        F2,
        F3,
        F4,
        F5,
        F6,
        F7,
        F8,
        F9,
        F10,
        G1,
        G2,
        G3,
        G4,
        G5,
        G6,
        G7,
        G8,
        G9,
        G10,
        H1,
        H2,
        H3,
        H4,
        H5,
        H6,
        H7,
        H8,
        H9,
        H10,
        deviceid,
        gamename,
        createdate,
        date,
        dataTime
FROM tlck_query
WHERE dataTime = '$everylogdate[dataTime]'
GROUP BY deviceid");
}

mysql_close($con);
?>